#pragma once

//#include "nullptr.hpp"
// These classes DO NOT get used directly.  Instead include the header of the actual policy you want to use
// and use the typedefs provided to save on fingercramp and increase readability ;)

namespace cpac
{

	template < class _Policy >
	class pooling_policy
	{
	public:
		static void* allocate_bytes(int in_count, char const* in_file = 0, int in_line = 0, char const* in_func = 0)
		{
			return _Policy::alloc_bytes(in_count, in_file, in_line, in_func);
		}
		static void deallocate_bytes(void* in_pointer)
		{
			_Policy::dealloc_bytes(in_pointer);
		}
		/// get the maximum size of a single allocation
		static int get_max_allocation_size()
		{
			return std::numeric_limits< int >::max();
		}

	private:
		// no instantiation
		pooling_policy()
		{ }
	};

	template < class _Policy, int _Alignment = 0 >
	class aligned_pooling_policy
	{
	public:
		// compile-time check alignment is available.  i.e. alignment == powerof2 and is no higher than 128
		typedef int is_valid_alignment[((_Alignment <= 128) && ((_Alignment & (_Alignment-1)) == 0)) ? +1 : -1];

		static void* allocate_bytes(int in_count, char const* in_file = 0, int in_line = 0, char const* in_func = 0)
		{
			return _Policy::alloc_bytes_aligned(_Alignment, in_count, in_file, in_line, in_func);
		}

		static void deallocate_bytes(void* in_pointer)
		{
			_Policy::dealloc_bytes_aligned(_Alignment, in_pointer);
		}

		/// get the maximum size of a single allocation
		static int get_max_allocation_size()
		{
			return std::numeric_limits< int >::max();
		}

	private:
		// no instantiation
		aligned_pooling_policy()
		{ }
	};

}
